<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
var forderSearchObj=new Object();
$(function(){
	forderSearchObj.folderId=$("#folderTree").tree("getRoot").id;
	//表格加载
	$('#folderAssoTable').datagrid({
	    url:'<c:url value="/docFolderAsso/docFolderAssoPage" />',
	    queryParams:forderSearchObj,//提交参数
	    
//	    toolbar:'#synFromToolbar',//表头工具栏
	    pagination:true,//显示分页  
	    pagePosition:'bottom',//分页栏出现位置
	    pageNumber:1,//初始页码
	    pageSize:10,//初始每页显示记录数量
	    singleSelect:true,
	    nowrap:false,//列的内容超出所定义的列宽时,自动换行
	    fitColumns:true,//设置为 true，则会自动扩大或缩小列的尺寸以适应网格的宽度并且防止水平滚动。
	    columns:[[
			{field:'FOLDER_ASSO_ID',title:'',width:"5%",formatter: function(value,row,index){
				return (index+1);
			}},
			{field:'ISSUE_NAME',title:'标题',width:"30%",formatter: function(value,row,index){ 
				return "<a href=\"#\" class=\"easyui-linkbutton\" plain=\"true\" onclick=\"openDonePage('"+row.ISSUE_ID+"','"+row.FORM_ID+"')\">"+value+"</a>";
			}},
			{field:'ISSUE_TYPE',title:'类型',width:"10%"},
			{field:'DISPLAY_NUMBER',title:'文号',width:"15%"},
			{field:'DESCRIPTION',title:'备注',width:"25%"},
			{field:'DEL_FLAG',title:'操作',width:"10%",formatter: function(value,row,index){ 
				return "<a href=\"#\" class=\"easyui-linkbutton\" plain=\"true\" onclick=\"moveFolder('"+row.FOLDER_ASSO_ID+"','P');\">转移</a><br><a href=\"#\" class=\"easyui-linkbutton\" plain=\"true\" onclick=\"delFolder('"+row.FOLDER_ASSO_ID+"');\">取消收藏</a>";
			}}
	    ]]
	});
	
	$("#folderDialog").dialog({
		title: '文件收藏',
	    width: 800,
	    height:300,
	    top:100,
	    closed: true,
	    cache: false,
	    modal: true,
	    buttons:[{
			text:'保存',
			handler:function(){
				if(saveData()){
					$('#folderAssoTable').datagrid("reload");
					$("#folderDialog").dialog("close");
				}else{
					$.messager.alert('提示','数据保存失败');
				}
			}
		},{
			text:'关闭',
			handler:function(){
				$("#folderDialog").dialog("close");
			}
		}]
	});
});

function openDonePage(issueId,formId){
	var url=_synergyContext+"/basic/donePage?issueId="+issueId+"&formId="+formId; 
	var winFeatures = "height="+(window.screen.height-80)+"px,width="+(window.screen.width-20)+"px,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no";
	window.open(url,'_blank',winFeatures);
}

function moveFolder(folderAssoId,folderType){
	$("#folderDialog").dialog('refresh',
			"<c:url value='/docFolderAsso/docFolderTreeInSynergy' />?folderAssoId="
			+folderAssoId+"&folderType="+folderType).dialog("open");
}
function delFolder(folderAssoId){
	$.ajax({
		   type: "POST",
		   url: "<c:url value='/docFolderAsso/docFolderAssoDel' />",
		   data: "folderAssoId="+folderAssoId,
		   async: false,
		   success: function(msg){
		     if(msg.state=="200"){
		    	 $('#folderAssoTable').datagrid("reload");
		     }else{
		    	 $.messager.alert('提示','取消收藏失败');
		     }
		   }
		});
}